    #include <stdio.h>  
    #include <string.h>  
    #include <unistd.h>  
    #include <stdlib.h>  
    #include <sys/socket.h>  
    #include <sys/un.h>  
      
    #define SERVER "server_sock"  
    #define CLIENT "client_sock"      
    int main(int argc,char *argv[])  
    {  
        int sockfd = 0;  
        struct sockaddr_un serveraddr, clientaddr;   
        unlink(CLIENT);   
      
        serveraddr.sun_family = AF_LOCAL;  
        strcpy(serveraddr.sun_path,SERVER);  

        clientaddr.sun_family = AF_LOCAL;  
        strcpy(clientaddr.sun_path,CLIENT);  
        socklen_t len = sizeof(clientaddr);      
        sockfd = socket(AF_LOCAL,SOCK_DGRAM,0);  
        int socksendfd = socket(AF_LOCAL,SOCK_DGRAM,0);
        if(sockfd < 0 || socksendfd < 0)  
        {  
            perror("socket error");  
            exit(-1);  
        }  
        if(bind(sockfd,(struct sockaddr *)&clientaddr,len) < 0)  
        {  
            perror("bind error");  
            close(sockfd);  
            exit(-1);  
        }  
        printf("Bind is ok\n");  
      
        while(1)  
        {  
            static int counter = 0;  
            char send_buf[20] = "";  
            counter++;  
            sprintf(send_buf,"Counter is %d",counter);  
            sendto(sockfd,send_buf,strlen(send_buf),0,(struct sockaddr*)&serveraddr,len);  
            printf("Send: %s\n",send_buf);  
            recvfrom(sockfd,send_buf,50,0,NULL,NULL); 
            printf("Recv: %s\n",send_buf);
            sleep(1);  
        }  
        return 0;  
    } 